/**************************************************************************
*  Black Knight - Chess Engine                                            *
*  Copyright (C) 2009  Victor Rusu                                        *
*                                                                         *
*  This program is free software: you can redistribute it and/or modify   *
*  it under the terms of the GNU General Public License as published by   *
*  the Free Software Foundation, either version 3 of the License, or      *
*  (at your option) any later version.                                    *
*                                                                         *
*  This program is distributed in the hope that it will be useful,        *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           *
*  GNU General Public License for more details.                           *
*                                                                         *
*  You should have received a copy of the GNU General Public License      *
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
**************************************************************************/

#ifndef LOGIC_ENGINE_H_
#define LOGIC_ENGINE_H_

#include <string>
#include "logic/position.h"
#include "logic/algorithm.h"

class Engine {
private:
    static Engine* engine_instance_;

    Algorithm* algorithm_;
    Position* current_position_;

    int clock_[Position::kSides];
    Position::side engine_side_;
    bool idle_mode_;
    int time_control_moves_;
    int time_control_length_;
    int time_control_increment_;

    Engine(std::string, double, std::string, Algorithm*);
    Engine(const Engine&);
    ~Engine();
    Engine& operator=(const Engine&);
public:
    const std::string kEngineName;
    const double kEngineVersion;
    const std::string kEngineAuthor;

    static void setup(std::string, double, std::string, Algorithm*);
    static Engine* instance();
    void main_loop();

    void new_game();
    void check_commands();
    void send_command(std::string);
    void check_time();
    void check_game_state();

    bool is_possible_move(std::string);
    void move();
};

#endif // LOGIC_ENGINE_H_
